package com.xinan.weixin.media;

import com.jfinal.ext.plugin.tablebind.TableBind;
import com.jfinal.kit.StringKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

import java.sql.Date;
import java.util.List;

@TableBind(tableName = "wx_img")
public class WxImg extends Model<WxImg> {
    public static final WxImg dao = new WxImg();

    //columns START
    private String ID = "id";  //主键
    private String IMG = "img";  //文件名称
    private String MEDIAID = "mediaId";  //
    private String CREATDATE = "creatdate";  //创建日期

    public void setId(int value) {
        set(ID, value);
    }

    public int getId() {
        return get(ID);
    }

    public void setImg(String value) {
        set(IMG, value);
    }

    public String getImg() {
        return get(IMG);
    }

    public void setMediaId(String value) {
        set(MEDIAID, value);
    }

    public String getMediaId() {
        return get(MEDIAID);
    }

    public void setCreatdate(Date value) {
        set(CREATDATE, value);
    }

    public Date getCreatdate() {
        return get(CREATDATE);
    }
    //columns END

    public List<WxImg> findAll() {
        return find("select * from wx_img");
    }

    /**
     * @param where
     * @return Record
     */
    public List<Record> findAlls(String where) {
        String sqlExp = " from wx_img";
        if (StringKit.notBlank(where)) {
            sqlExp += " where " + where;
        }
        return Db.find("select * " + sqlExp);

    }

    public Page<WxImg> page(int pageNumber, int pageSize, String where) {
        String sqlExp = "from wx_img";
        if (StringKit.notBlank(where)) {
            sqlExp += " where " + where;
        }
        return paginate(pageNumber, pageSize, "select *", sqlExp);
    }
}

